import pymysql

uid='ada'
sex='man'
speed_id='7'
id=1

conn = pymysql.connect(host='10.1.1.30',user='root',password='P@ssw0rd',database='db1',charset='utf8')
cursor=conn.cursor()
sql_command = 'insert into user (name,sex) values(%s,%s);'
while True:
    id +=1
    intid = str(id)
    uid1=uid+intid
    cursor.execute(sql_command,(uid1,sex))
    conn.commit()
    if id > 3000:
        sex='woman'
    elif id > 30000:break
    #print (id)      
cursor.close()
conn.close()